use std::fmt;
pub type IndexResult<T> = Result<T,IndexError>;

#[derive(Debug)]
pub enum IndexError {
    PathCreate(std::io::Error),
    DbOpen(sled::Error),
    FpInsert(sled::Error),
    FpFind(sled::Error),
    SfInsert(sled::Error),
    SfFind(sled::Error),
}

impl fmt::Display for IndexError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::PathCreate(e) => write!(f,"Error index store create path error:{}",e),
            Self::DbOpen(e) => write!(f,"Error index open db error:{}",e),
            Self::FpInsert(e) => write!(f,"Error insert fp error:{}",e),
            Self::FpFind(e) => write!(f,"Error find fp error:{}",e),
            Self::SfInsert(e) => write!(f,"Error insert sf error:{}",e),
            Self::SfFind(e) => write!(f,"Error find sf error:{}",e),
        }
    }
}

impl std::error::Error for IndexError {}